import request from '@/utils/api'

// 创建评论
export const createComment = (commentData) => {
  return request.post('/api/comments', commentData)
}

// 更新评论
export const updateComment = (id, commentData) => {
  return request.put(`/api/comments/${id}`, commentData)
}

// 删除评论
export const deleteComment = (id) => {
  return request.delete(`/api/comments/${id}`)
}

// 删除笔记的所有评论
export const deleteCommentsByNoteId = (noteId) => {
  return request.delete(`/api/comments/note/${noteId}`)
}

// 获取单个评论（包含用户信息）
export const getCommentById = (id) => {
  return request.get(`/api/comments/${id}`)
}

// 获取笔记的评论树（包含用户信息和嵌套结构）
export const getCommentsTreeByNoteId = (noteId) => {
  return request.get(`/api/comments/note/${noteId}`)
}

// 获取用户的所有评论
export const getCommentsByUserId = (userId) => {
  return request.get(`/api/comments/user/${userId}`)
}

// 获取评论的回复（包含用户信息）
export const getRepliesByParentId = (parentId) => {
  return request.get(`/api/comments/reply/${parentId}`)
}

// 获取笔记的评论总数
export const getCommentCountByNoteId = (noteId) => {
  return request.get(`/api/comments/note/${noteId}/count`)
}

// 获取用户的评论总数
export const getCommentCountByUserId = (userId) => {
  return request.get(`/api/comments/user/${userId}/count`)
}